Skip to content

fix: resolve relative symlinks in rules files using realpath of parent directory#11788

Open
p12tic wants to merge 1 commit intoRooCodeInc:mainfrom
p12tic:fix-symlinked-rules
Open

fix: resolve relative symlinks in rules files using realpath of parent directory#11788
p12tic wants to merge 1 commit intoRooCodeInc:mainfrom
p12tic:fix-symlinked-rules

Conversation

@p12tic
Copy link
Contributor

@p12tic p12tic commented Feb 27, 2026

Related GitHub Issue

Closes: #11786

Description

When a .roo/rules directory is itself a symlink to an external directory, and files inside are relative symlinks (e.g., ../1-project.txt), the symlink targets were incorrectly resolved relative to the access path instead of the real filesystem path.

Use fs.realpath() on the symlink's parent directory before resolving relative targets, matching how the OS resolves relative symlinks.

Test Procedure

Reproduced the filesystem structure shown in the project, verified that issue exists by viewing "Modes -> Preview system prompt". The issue is reproducible before the bug fix and no longer is reproducible after the bug fix.

Pre-Submission Checklist

  • Issue Linked: This PR is linked to an approved GitHub Issue (see "Related GitHub Issue" above).
  • Scope: My changes are focused on the linked issue (one major feature/fix per PR).
  • Self-Review: I have performed a thorough self-review of my code.
  • Testing: New and/or updated tests have been added to cover my changes (if applicable).
  • Documentation Impact: I have considered if my changes require documentation updates (see "Documentation Updates" section below).
  • Contribution Guidelines: I have read and agree to the Contributor Guidelines.

Screenshots / Videos

n/a

Documentation Updates

Not needed

Interactively review PR in Roo Code Cloud

…t directory

When a .roo/rules directory is itself a symlink to an external directory,
and files inside are relative symlinks (e.g., ../1-project.txt), the
symlink targets were incorrectly resolved relative to the access path
instead of the real filesystem path.

Use fs.realpath() on the symlink's parent directory before resolving
relative targets, matching how the OS resolves relative symlinks.
@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. bug Something isn't working labels Feb 27, 2026
@hannesrudolph
Copy link
Collaborator

@roomote review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Relative symlinks in rules files not resolved correctly when accessed through a symlinked directory

2 participants